<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('产品销量纪录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>厂家名称：</label>
                                <input type="text" name="factoryName"/>
                            </li>
                            <li>
                                <label>产品名称：</label>
                                <input type="text" name="partsName"/>
                            </li>
                            <li>
                                <label>规格名称：</label>
                                <input type="text" name="attributeName"/>
                            </li>
                            <li>
                                <label>核算人：</label>
                                <input type="text" name="createId"/>
                            </li>
                            <li class="select-time">
                                <label>核算时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCreateTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCreateTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="addOther()" shiro:hasPermission="zsyh:partsRebate:add">
                    <i class="fa fa-plus"></i> 新增销量/销售额核算记录
                </a>
                <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="zsyh:partsRebate:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="zsyh:partsRebate:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="zsyh:partsRebate:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:partsRebate:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:partsRebate:remove')}]];
        var isDelFlags = [[${@dict.getType('zsyh_delflags')}]];
        var prefix = ctx + "zsyh/partsRebate";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/addOther",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "产品销量纪录",
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'factoryName',
                    align: 'center',
                    title: '厂家名称'
                },{
                        field: 'attributeLogo',
                        align: 'center',
                        title: '主图',
                        formatter: function (value, row, index) {
                            return $.table.imageView(value);
                        }
                    },
                {
                    field: 'partsName',
                    align: 'center',
                    title: '产品名称'
                },
                {
                    field: 'attributeName',
                    align: 'center',
                    title: '规格名称'
                },
                {
                    field: 'rebateNumber',
                    align: 'center',
                    title: '核算销量/销售额'
                },
                {
                    field: 'rebatePrice',
                    align: 'center',
                    title: '核算单价'
                },
                {
                    field: 'rebateMoney',
                    align: 'center',
                    title: '核算服务费'
                },
                {
                    field: 'createId',
                    align: 'center',
                    title: '核算人'
                },
                    {
                        field: 'createTime',
                        align: 'center',
                        title: '核算时间'
                    },{
                        field: 'delFlags',
                        title: '删除标记',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(isDelFlags, value);
                        }
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        var currentDate = new Date();
                        var checkTime = new Date(row.createTime);
                        if(checkTime.getFullYear() == currentDate.getFullYear() && checkTime.getMonth() == currentDate.getMonth()){
                            if(row.delFlags == "0"){
                                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editRebate(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            }
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function editRebate(id) {
            var url = prefix + "/edit/"+id;
            $.modal.open("修改产品销量纪录", url, '1000', '550');
        }


        function addOther() {
            var url = prefix + "/addOther";
            $.modal.open("添加产品销量记录", url, '1000', '650');
        }

    </script>
</body>
</html>